/**
* @file        ut_log_macros
* @brief       
* @version     1.0.0
* @author      Changlin.Jing 
* @date        2023/7/27 14:00
* @copyright   Copyright  2022 Langge Software Co., Ltd. All rights reserved.
*/
#ifndef LANGGE_VDR_UT_LOG_MACROS_H
#define LANGGE_VDR_UT_LOG_MACROS_H
#include "log/vdr_logs.h"

#define LOG_LEVEL_TRACE 0
#define LOG_LEVEL_DEBUG 10000
#define LOG_LEVEL_INFO 20000
#define LOG_LEVEL_WARN 30000
#define LOG_LEVEL_ERROR 40000
#define LOG_LEVEL_FATAL 50000
#ifdef WIN32
#define __VDR__FILENAME__ (strrchr(__FILE__, '\\') ? (strrchr(__FILE__, '\\') + 1):__FILE__)
#else
#define __VDR__FILENAME__ (strrchr(__FILE__, '/') ? (strrchr(__FILE__, '/') + 1):__FILE__)
#endif

/**
 * @brief 初始化导航日志
 * @param logDir         - 导航日志输出目录
 * @param maxFileSize    - 单个日志最大尺寸
 * @param maxBackupIndex - 日志允许最大数量
 * @param isSyncTerminal - 是否同步终端输出
 */
inline void VDR_LOG_INIT(const char *logDir,const char *prefix,const char *logId,bool isSyncTerminal = false)
{
    vdr::VdrLogs::GetInstance().Init( prefix,logDir,logId,isSyncTerminal);
}

#define VDR_LOG_DEBUG(logid, content)                                            \
    vdr::VdrLogs::GetInstance().WriteLog(logid, LOG_LEVEL_DEBUG, \
                                                  __VDR__FILENAME__, __LINE__, __FUNCTION__, content);

#define VDR_FMT_LOG_DEBUG(logid,format, ...)                                    \
    vdr::VdrLogs::GetInstance().WriteFormatLog(logid,LOG_LEVEL_DEBUG, \
                                                  __VDR__FILENAME__, __LINE__, __FUNCTION__, format, __VA_ARGS__);

#define VDR_LOG_INFO(logid, content)                                            \
    vdr::VdrLogs::GetInstance().WriteLog(logid, LOG_LEVEL_INFO, \
                                                  __VDR__FILENAME__, __LINE__, __FUNCTION__, content);
#define VDR_LOG_WARN(logid, content)                                            \
    vdr::VdrLogs::GetInstance().WriteLog(logid, LOG_LEVEL_WARN, \
                                                  __VDR__FILENAME__, __LINE__, __FUNCTION__, content);
#define VDR_LOG_ERROR(logid, content)                                            \
   vdr::VdrLogs::GetInstance().WriteLog(logid, LOG_LEVEL_ERROR, \
                                                  __VDR__FILENAME__, __LINE__, __FUNCTION__, content);

#endif //LANGGE_VDR_UT_LOG_MACROS_H
